package demo13;

/**
 * @program: qy158
 * @description:
 * @author: 闫克起2
 * @create: 2022-11-01 09:08
 **/
public class TestSleep {
    public static void main(String[] args) {
        SleepDemo sleepDemo=new SleepDemo();
        sleepDemo.start();
    }
}
class SleepDemo extends Thread{

    @Override
    public void run() {
        for (int i = 0; i <20 ; i++) {
            try {
                Thread.sleep(1000); //当前线程获取到cpu后，执行到该处代码时，会休眠1秒。休眠过后会继续执行。
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName()+"~~~~~~~~~~~"+i);
        }
    }
}
